package com.wink.dt;

import java.util.ArrayList;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;

import com.google.gson.Gson;
import com.wink.charity.CharityList;

@XmlRootElement(name = "topiclist")
@XmlAccessorType(XmlAccessType.FIELD)
public class TopicList {
	@XmlElementRef
	ArrayList<Topic> data;

	/**
	 * must have
	 */
	public TopicList() {
	}

	public TopicList(ArrayList<Topic> data) {
		this.data = data;
	}

	public ArrayList<Topic> getList() {
		return data;
	}

	public void setData(ArrayList<Topic> data) {
		this.data = data;
	}
	
	public static String toJson(TopicList topicList) {
		Gson gson = new Gson();
		String json = gson.toJson(topicList, TopicList.class);
		System.out.println("---> TopicList: json  " + json);
		return json;
	}
	
	public static TopicList fromJson(String json) {
		Gson gson = new Gson();
		TopicList retTl = gson.fromJson(json, TopicList.class);
		System.out.println("---> TopicList: fromJson  " + retTl.toString());
		return retTl;
	}
}
